package com.example.servlet;

import com.example.dao.NovelDao;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;

@WebServlet("/NovelDeleteServlet")
public class NovelDeleteServlet extends HttpServlet {
    public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
        request.setCharacterEncoding("utf-8");
        String novel_id = request.getParameter("novel_id");
        NovelDao novelDao = new NovelDao();
        int affextedRow = novelDao.deleteNovelById(Integer.parseInt(novel_id));
        if(affextedRow>0){
            request.setAttribute("msg","删除成功");
            response.sendRedirect(request.getContextPath()+"/admin/novel.jsp");
            return;
        }
        request.setAttribute("msg","删除失败");
        response.sendRedirect(request.getContextPath()+"/admin/novel.jsp");
    }
    public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
        doGet(request, response);
    }
}
